<?php

session_start();
$EventID=$_POST['EventID'];
$EventName=$_POST['EventName'];
$Price=$_POST['Price'];
$Date=$_POST['Date'];
$Time=$_POST['Time'];
$VenueID=$_POST['VenueID'];
$Ad_ID=$_POST['Ad_ID'];
$SponsorID=$_POST['SponsorID'];

$dbConn = odbc_connect("EventDB","MyUser","Temp123");
if (!$dbConn)
  {
  die('Could not connect: ' . odbc_error());
  }
  
$sql = "INSERT into Events values($EventID,'$EventName',$Price,$Date,$Ad_ID,$SponsorID,$VenueID,$Time)";

$rs = odbc_exec($dbConn, $sql);

odbc_close($dbConn);

echo "You entered the following Event Information<br /><br />";

echo '<span class="label">EventID:</span>' . $EventID . "<br />\n";
echo '<span class="label">Name:</span>' . $EventName . "<br />\n";
echo '<span class="label">Price:</span>' . $Price . "<br />\n";
echo '<span class="label">Date:</span>' . $Date . "<br />\n";
echo '<span class="label">Time:</span>' . $Time . "<br />\n";

$sql = "SELECT VenueName FROM Venue WHERE VenueID=$VenueID";

$rs = odbc_exec($dbConn, $sql);

while(odbc_fetch_row($rs))
{
	$VenueName = odbc_result($rs, "VenueName");
	
	echo '<span class="label">Venue Name (ID):</span>' . $VenueName . " ($VenueID)<br />\n";
}

$sql = "SELECT SponsorName FROM Sponsors WHERE SponsorID=$SponsorID;";

$rs = odbc_exec($dbConn, $sql);

while(odbc_fetch_row($rs))
{
	$SponsorName = odbc_result($rs, "SponsorName");
	
	echo '<span class="label">Sponsor Name (ID):</span>' . $SponsorName . " ($SponsorID)<br />\n";
}

echo '<span class="label">Advertising ID:</span>' . $Ad_ID . "<br />\n";